package controllers;

import static org.fun4j.Template.fn;

import java.math.BigInteger;

import org.fun4j.Function;
import org.fun4j.compiler.CompilationException;

import models.Map;
import views.GameView;

public class LevelController {

	private static int level = 0;
	
	//Construtor
	public static void startNewGame(){
		
		Function inc = null;
		try {
			inc = fn("(lambda (x) (+ x 1))");
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		level = Integer.valueOf(inc.apply(new BigInteger(""+level)).toString());
		SpawnedMobsController.setEnable(true);
		TowerController.setEnable(true);
		Map map = new Map();		
		GameView gameView = new GameView(map, level);
		GameController gameController = new GameController(gameView);
		gameView.setController(gameController); 
		SpawnedMobsController spawnedMobsController = new SpawnedMobsController(gameView, map, level);
		spawnedMobsController.initMobs();
	}
	
	//Getters
	public static int getLevel(){
		return level;
	}
	
	//Setters
	public static void setLevel(int level){
		LevelController.level = level;
	}

}
